<!doctype html>
<html class="no-js">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>产品编辑</title>

  <!-- Set render engine for 360 browser -->
  <meta name="renderer" content="webkit">

  <!-- No Baidu Siteapp-->
  <meta http-equiv="Cache-Control" content="no-siteapp"/>

  <link rel="icon" type="image/png" href="assets/i/favicon.png">

  <!-- Add to homescreen for Chrome on Android -->
  <meta name="mobile-web-app-capable" content="yes">
  <link rel="icon" sizes="192x192" href="assets/i/app-icon72x72@2x.png">

  <!-- Add to homescreen for Safari on iOS -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
  <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">

  <!-- Tile icon for Win8 (144x144 + tile color) -->
  <meta name="msapplication-TileImage" content="assets/i/app-icon72x72@2x.png">
  <meta name="msapplication-TileColor" content="#0e90d2">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <link rel="stylesheet" href="assets/css/amazeui.min.css">
  
    <script src="assets/js/jquery.min.js"></script>
	<script src="assets/js/amazeui.js"></script>
	<script src="assets/js/memu.js"></script>
	<script src="assets/js/baiduTemplate.js"></script>
	 <script src="assets/js/PublicFunction.js"></script>
  	<script src="assets/js/product.js"></script>

  <style type="text/css">
  div{
  	word-wrap: break-word; 
  	word-break: normal;
  }
  table{table-layout: fixed;}
	td{word-break: break-all; word-wrap:break-word;}
  .du_title{
  	width: 30%; 
  	float:left; 
  	height: 35px;   
  	line-height:35px;   
  	text-align: center;
  	margin-bottom: 10px; 
  }
  .du_input{
  	width: 80%; 
  	margin:auto auto;
  	 margin-bottom: 10px;
  }
.select_type{
	width: 25%;
	 float: left;
	
	
}
select{
		width: 100%;
	 float: left;
	
	 display:block;/*内联对象需加*/
	
		word-break:keep-all;/* 不换行 */
white-space:nowrap;/* 强制在同一行内显示所有文本，直到文本结束或者遭遇 br 对象。不换行 */
overflow:hidden;/* 内容超出宽度时隐藏超出部分的内容 */
text-overflow:ellipsis;/* IE 专有属性，当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用。*/
}
  </style>
</head>
<body>



<div id="parent" >



<div data-am-sticky id="header">
	<header data-am-widget="header" class="am-header am-header-default">
		<div class="am-header-left am-header-nav">
			<a  href="javascript:backA()" class="">
				
				<i class="am-header-icon am-icon-chevron-left"></i>
			</a>
		</div>
		<h1 class="am-header-title" style="font-size:14px;">
			产品详情
		</h1>
		<div class="am-header-right am-header-nav">
			<a href="javascript:menu()" class="">
				<i class="am-header-icon am-icon-list-ul"></i>
			</a>
			
		</div>	
	
	<!-- 遮罩-->
	<div class="am-modal am-modal-no-btn" tabindex="-1" id="memu-modal">
  
	</div>
	</header>
</div>

	
		
	<div style="width: 100%;" id="div_info">
	<script type="text/javascript" id= "info">
		<ul data-am-widget="gallery" class="am-gallery am-avg-sm-3
  			am-avg-md-3 am-avg-lg-4 am-gallery-default" data-am-gallery="{ pureview: true }">
 		 	<li>
    			<div class="am-gallery-item">
      				<a href="" class="" id = "a_img_1">
        				<img  src="<%=server%><%=list.ProductImg1%>" alt="添加图片" id="img_1"/>
        			 </a>
        				<h3 class="am-gallery-title">
        					<button type="button" class="am-btn am-btn-danger am-btn-xs"  onclick="deleteimg('img_1')">删除</button>
							 <button type="button" class="am-btn am-btn-primary am-btn-xs" onclick="openPhotoMenu('img_1')">修改</button>
							 
						</h3>
        			
     				
    			</div>
 		 	</li>
  			<li>
   				 <div class="am-gallery-item">
     			 	<a href="" class="" id = "a_img_2">
        				<img src="<%=server%><%=list.ProductImg2%>" alt="添加图片"/  id="img_2">
        			</a>
        				<h3 class="am-gallery-title">
        					<button type="button" class="am-btn am-btn-danger am-btn-xs"  onclick="deleteimg('img_2')">删除</button>
							 <button type="button" class="am-btn am-btn-primary am-btn-xs" onclick="openPhotoMenu('img_2')">修改</button>
						</h3>
        			
      			
    		</div>
  			</li>
  			
  			<li>
    			<div class="am-gallery-item">
      				<a href="" class="" id = "a_img_3">
       					 <img src="<%=server%><%=list.ProductImg3%>" alt="添加图片" id="img_3" />
       				</a>
        					<h3 class="am-gallery-title">
        						<button type="button" class="am-btn am-btn-danger am-btn-xs" onclick="deleteimg('img_3')">删除</button>
								<button type="button" class="am-btn am-btn-primary am-btn-xs" onclick="openPhotoMenu('img_3')">修改</button>
								
							</h3>
        			
      			
    			</div>
  			</li>
  			
		</ul>
	
	
				<input name="input_img_1" type="hidden"  id="input_img_1" value="<%=list.ProductImg1%>">
				<input name="input_img_2" type="hidden"  id="input_img_2" value="<%=list.ProductImg2%>">
				<input name="input_img_3" type="hidden"  id="input_img_3" value="<%=list.ProductImg3%>">
			
	<form class="am-form" id ="myform">
		<div style="width: 100%;height: 46px; padding-top:6px ;">
			 
			
				
   					<div class="select_type">
   						<select style="width:100%;" name="select1"  class="am-input-sm select1">
							<!-- <option value="option3">1级类目</option> -->
						</select>
					</div>
   					<div class="select_type">
   						<select style="width:100%; " name="select2" class="am-input-sm select2" >
							<!-- <option value="option3">2级类目1111</option> -->
						</select>
   					</div>
   					<div class="select_type">
   						<select style="width:100%; " name="select3" class="am-input-sm select3" >
							<!-- <option value="option3">3级类目</option> -->
						</select>
   					</div>
   					<div class="select_type">
   						<select style="width:100%; " name="select4" class="am-input-sm select4" >
							<!-- <option value="option3">4级类目</option -->
						</select>
   					</div>
   			
   			
	 </div>

		<div style="width: 100%;  padding-top:6px ;">
			
  			<div class="du_input">
  			<span>产品标题</span>
  				 <input class="am-form-field am-input-sm" name="name" type="text" placeholder="产品标题" value="<%=list.name%>" />
  			</div>
  			
  			
  			
  			<div style="" class="du_input">
  				<span>价格</span>
  				 <input class="am-form-field am-input-sm" name="price" type="text" placeholder="价格" value="<%=list.Price%>" //>
  			</div>
  			
  			
  		
  			<div style="" class="du_input">
  			<span>库存</span>
  				 <input class="am-form-field am-input-sm" name="stock" type="text" placeholder="库存"value="<%=list.Stock%>" />
  			</div>
  			
  			<div style="	 margin-bottom: 0px;" class="du_input" >
  				<span>品规</span>
  			</div>
  			<div style="" class="du_input">
  			
  				<div  style="float: left; width: 70%;" >
  				 	<input type="text" name="specifications1"  id ="specifications1" class="am-form-field am-radius" placeholder="品规"value="<%=list.specifications%>" />
   				</div>	
   				
   				<div  style="float: right; width: 25%;" >
					<select style="width:100%;" name="specifications_type" id = "specifications_type" class="am-input ">
							 <option value="/箱">/箱</option>
					</select>
				</div>
  			</div>
  			
  			
		</div>
		
		
		<div class="am-scrollable-horizontal" >
				<table class="am-table am-table-striped " style=" width: 100%;">
					
					<tr>
					<td>
						<h3 style="text-align:left;">产品描述:</h3>
						<!-- <blockquote>
  							<p>产品描述:产品描述:产品描述:产品描述:产品描述:产品描述:</p>
  							
						</blockquote> -->
						 <textarea class="" name="description" rows="3" id="doc-ta-1" style="width: 100%;"><%=list.description%></textarea>
					</td>
					</tr>
				</table>
		</div>
		<input name="id" type="hidden"  id="id" value="<%=list.id%>">
		</form>
		</script>
	</div>
		</br>	</br>	</br>
		
<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert" title="-1">
  <div class="am-modal-dialog">
    <div class="am-modal-bd">
   		 <button type="button" class="am-btn am-btn-default am-radius" onclick="gotoPhoto('2','1')">拍照</button>
   	 	 <button type="button" class="am-btn am-btn-default am-radius" onclick="getPhoto('2','1')">选择相册</button>
     <!--  	 <img class="am-circle" src="assets/img/i_p.png" width="50" height="50" alt="调用摄像机" onclick="gotoPhoto()"/>  
		 <img class="am-circle" src="assets/img/i_p.png" width="70" height="70" alt="调用摄像机" onclick="getPhoto()"/> -->
						
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn" id ="close_select">关闭</span>
    </div>
  </div>
</div>
			


	
</div>

 <div data-am-widget="navbar" class="am-navbar am-cf am-navbar-default "id="">
  <ul class="am-navbar-nav am-cf am-avg-sm-4" style="width:100%; padding:0 0; ">
    <li style="background-color:#f90461;">
      <a href="javascript:actuator('updateProduct()')" class="">
        
        <span class="am-navbar-label">保存</span>
      </a>
    </li>

  </ul>
</div>


<script type="text/javascript">


var img_num = "";  

function init(w,h) {
	$('#my-alert').on('closed.modal.amui', function(){
		  $("#my-alert").attr("title","-1");
		});
	$('#my-alert').on('opened.modal.amui', function(){
		  $("#my-alert").attr("title","1");  
		});
		
	//生成menu
	generateMenu();
	
	
	//根据ID 获取产品
	var sjson =  DucumentFunction.getProductbyId();
	var pr_json = "";
	 if(sjson!=null&&sjson.length>0){
		 var json = strToJson(sjson);
		 var serverpath= Public_method.getServerPath()+"upload/";
		 var data={
				server:serverpath,
					list:json
				} 
			var bat=baidu.template;
			var title_img_html=bat('info',data);
			//渲染
			 document.getElementById('div_info').innerHTML=title_img_html;  
			 pr_json =  DucumentFunction.getProductAllType(json.ProductType);
	 }
	
	//类目展示选择功能
	addOneLevel();
	if(pr_json!=null&&pr_json.length>0){
		setop(pr_json,".select1","1"); 
		
	}
	
	
	
	var specifications1val = $("#specifications1").val();
	var specifications1valnumber = specifications1val.replace(/[^0-9]/ig,""); //产品规格数量
	var specifications1valtype = specifications1val.replace(specifications1valnumber,"");//产品规格类型
	$("#specifications1").attr("value",specifications1valnumber );
	

}
//删除产品
function deleteimg(id){
	img_num = id;
	 $("#"+img_num).attr("src",""); //设置图片
	 $("#a_"+img_num).attr("href",""); //A标签
	 $("#input_"+img_num).attr("value","");//设置值
}
function setimg(imgs){
	 $("#"+img_num).attr("src",imgs); //设置图片
	 $("#a_"+img_num).attr("href",imgs); //A标签
	 $("#input_"+img_num).attr("value",imgs);//设置值
	 $("#close_select").click();

 }
 
 function openPhotoMenu(id){
	 img_num = id;
	 var $modal = $('#my-alert');
	 $modal.modal();
 }

 //返回键
 function onBackPressed(){
	 var isopen = $("#my-alert").attr("title");
		if(isopen == "1"){
			$("#close_select").click();
		}
		else{
			Public_method.finishActivity();
		}
	
	
 }
 
 function updateProduct(){
	var input_img_1 =  $("#input_img_1").val();
	var input_img_2 =  $("#input_img_2").val();
	var input_img_3 =  $("#input_img_3").val();
	var specifications = $("#specifications1").val()+$("#specifications_type").val();
	var data =$("#myform").serialize();
	 data = decodeURIComponent(data,true); 
	 if(input_img_1!=null&&input_img_1.length>0){
		 data= data+"&input_img_1="+input_img_1;
	 }
	 if(input_img_2!=null&&input_img_2.length>0){
		 data= data+"&input_img_2="+input_img_2;
	 }
	 if(input_img_3!=null&&input_img_3.length>0){
		 data= data+"&input_img_3="+input_img_3;
	 }
	 if(specifications!=null&&specifications.length>0){
		 data= data+"&specifications="+specifications;
	 }
	 //添加username
	 var username = getLoginUserName();
	 data= data+"&username="+username;
	 DucumentFunction.updateProduct(data);
 }
 
 
</script>
</body>
</html>
